feat: add page renderer detection tool#16
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a new Page tool to detect the current Mini Program renderer (WebView vs Skyline) and refines the guidance shown to users for cross-component bounding client rect queries.
Changes:
- Add
page_getRenderertool that callswx.getSkylineInfoSync()and returns the inferred renderer plus raw diagnostics. - Register the new tool in the Page tools list.
- Update
element_getBoundingClientRectdescription to clarify howselector/innerSelectorshould be used with custom components.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/tools/page.ts |
Adds and registers page_getRenderer renderer-detection tool and outputs diagnostics. |
src/tools/element.ts |
Updates tool description text to clarify selector behavior across custom components. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
感谢贡献!这里我建议调整一下实现方向:不新增 原因有两个:
我这边实测到一个反例: {
"renderer": "webview",
"skylineInfo": {
"isSupported": true,
"version": "1.4.7"
}
}建议改法:
const runtimeInfo = await miniProgram.evaluate(() => {
const pages = getCurrentPages();
const page = pages[pages.length - 1];
return {
renderer: page?.renderer ?? null,
skylineInfo:
typeof wx.getSkylineInfoSync === "function"
? wx.getSkylineInfoSync()
: null,
};
});这样 |
可以的,注意把另一个工具的提示词帮我合并下。我加这个主要是因为webview支持热重载,skyline需要重新build,我在自己工程里加了自动切窗口调用build的脚本。不过我在开发者工具里用的时候skyline页面的isSupported都是和在ide控制的开关状态一致,挺奇怪的。 |
Summary
Validation